Skip to content

[WC-3050] Retrieve pdfjs worker locally instead of cdn - #1817

Merged
gjulivan merged 1 commit into
mainfrom
document-viewer-local-pdfjs
Sep 10, 2025
Merged

[WC-3050] Retrieve pdfjs worker locally instead of cdn#1817
gjulivan merged 1 commit into
mainfrom
document-viewer-local-pdfjs

Conversation

@gjulivan

@gjulivan gjulivan commented Aug 10, 2025

Copy link
Copy Markdown
Collaborator

Pull request type


Description

pdfjs-dist version has to be the same with react-pdf dependency
https://github.com/wojtekmaj/react-pdf/blob/5e0d135f5d1d3a3cec4628a2fc05a4a8f0bed9e7/packages/react-pdf/package.json#L60
this version use "4.8.69"

@gjulivan
gjulivan force-pushed the document-viewer-local-pdfjs branch 6 times, most recently from 03e05ee to 2f12295 Compare August 11, 2025 20:01
@gjulivan
gjulivan marked this pull request as ready for review August 11, 2025 20:02
@gjulivan
gjulivan requested a review from a team as a code owner August 11, 2025 20:02
@gjulivan gjulivan changed the title Retrieve pdfjs worker locally instead of cdn [WC-3050] Retrieve pdfjs worker locally instead of cdn Aug 11, 2025
@gjulivan
gjulivan force-pushed the document-viewer-local-pdfjs branch 2 times, most recently from 7908040 to 2bddeee Compare August 12, 2025 11:15
iobuhov
iobuhov previously approved these changes Aug 14, 2025

@iobuhov iobuhov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gjulivan
gjulivan force-pushed the document-viewer-local-pdfjs branch 2 times, most recently from 27561ca to 6d4485d Compare August 19, 2025 22:20
@gjulivan
gjulivan force-pushed the document-viewer-local-pdfjs branch 2 times, most recently from e7af5a5 to c05c050 Compare August 29, 2025 08:20
@gjulivan gjulivan assigned gjulivan and unassigned gjulivan Aug 29, 2025
@gjulivan
gjulivan force-pushed the document-viewer-local-pdfjs branch from c05c050 to 3c1a7c7 Compare August 29, 2025 08:35
@gjulivan gjulivan closed this Aug 29, 2025
@gjulivan gjulivan reopened this Aug 29, 2025
@gjulivan
gjulivan force-pushed the document-viewer-local-pdfjs branch from 3c1a7c7 to a69bc3e Compare August 29, 2025 09:38
Copilot AI review requested due to automatic review settings August 29, 2025 09:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the Document Viewer widget to bundle PDF.js worker files locally instead of loading them from a CDN, improving Content Security Policy (CSP) compliance. The changes involve downgrading the pdfjs-dist dependency to maintain compatibility with react-pdf.

  • Configures Rollup to copy PDF.js worker files, cmaps, and standard fonts to the local build
  • Updates PDF.js worker URL configuration to use local paths instead of CDN URLs
  • Downgrades pdfjs-dist from version 5.0.375 to 4.8.69 for react-pdf compatibility

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

File Description
rollup.config.mjs Adds copy plugin to bundle PDF.js worker files and dependencies locally
package.json Bumps version to 1.1.0 and downgrades pdfjs-dist to 4.8.69 for compatibility
PDFViewer.tsx Updates worker and resource URLs to use local paths instead of CDN
CHANGELOG.md Documents the change to local PDF.js worker bundling
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread packages/pluggableWidgets/document-viewer-web/rollup.config.mjs
@gjulivan
gjulivan force-pushed the document-viewer-local-pdfjs branch 2 times, most recently from 3c4fbde to cdfa90f Compare September 4, 2025 11:14
@gjulivan
gjulivan force-pushed the document-viewer-local-pdfjs branch from cdfa90f to 4ff3123 Compare September 6, 2025 20:13
@gjulivan
gjulivan force-pushed the document-viewer-local-pdfjs branch from 4ff3123 to bfd3a6a Compare September 9, 2025 12:08
@gjulivan
gjulivan enabled auto-merge (rebase) September 10, 2025 13:20
@gjulivan
gjulivan merged commit d404bae into main Sep 10, 2025
14 checks passed
@gjulivan
gjulivan deleted the document-viewer-local-pdfjs branch September 10, 2025 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants